package com.lu.controller;

import com.lu.entity.Live;
import com.lu.entity.Student;
import com.lu.service.live.LiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class LiveController {
    @Autowired
    private LiveService liveService;

    //返回查询所有入住的数据
    @GetMapping("/selectLive")
    public List<Live> selectLive() {
        return liveService.getLiveData();
    }

    //根据id删除入住数据
    @DeleteMapping("/deleteLive/{id}")
    public void deleteLive(@PathVariable Integer id) {
        liveService.deleteLive(id);
    }

    //根据id查询入住数据
    @GetMapping("/getLiveById")
    public List<Live> getLiveById(@RequestParam Integer id) {
        return liveService.getLiveDataById(id);
    }

    //修改入住数据
    @PutMapping("/updateLive")
    public void updateLive(@RequestBody Live live) {
        liveService.updataLiveData(live);
    }

    //添加入住数据
    @PostMapping("/insertLiveData")
    public void insertLiveData(@RequestBody Live live) {
        liveService.insertLiveData(live);
    }

    //模糊查询
    @PostMapping("/getLiveData")
    public List<Live> getLiveData(@RequestBody Live live) {
        return liveService.getfindLive(live);
    }
}
